import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import monkey, { cdn } from "vite-plugin-monkey";
import path from "path"
// https://vitejs.dev/config/
export default defineConfig(({ command })=>{
  console.log('command: ', command);
  return {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'),
      }
    },
    // build:{
    //   terserOptions: {
    //     compress: {
    //       drop_console: command === 'build',
    //       // 默认是true
    //       drop_debugger: command === 'build'
    //     }
    //   },
    // },
    plugins: [
      vue(),
      monkey({
        entry: "src/main.ts",
        userscript: {
          name: "saasweb拦截调试工具-saasweb-devtool",
          icon: "https://vitejs.dev/logo.svg",
          namespace: "npm/vue-router-tool",
          match: ["https://*/*", "http://*/*"],
          author: "shixiaoshi",
          version:"1.1.1",
          description:"vue项目多路由切换；路径智能补全；saasweb生产界面调试本地服务。",
          noframes:true,
          license:"MIT",
          connect:"localhost",
          grant:["unsafeWindow","GM_setValue","GM_registerMenuCommand","GM_listValues","GM_getValue","GM_deleteValue"],
          "run-at":"document-start"
        },
        build: {
          externalGlobals: {
            vue: cdn.jsdelivr("Vue", "dist/vue.global.prod.js"),
          },
        },
      }),
    ],
  }
});
